package com.sbeam.controller;

import com.sbeam.pojo.Rights;
import com.sbeam.service.RightsService;
import com.sbeam.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/rights")
@CrossOrigin
public class RightsController {

    @Autowired
    private RightsService rightsService;

    @GetMapping("/getRightsList")
    public SysResult getRightsList(Integer level){
        List<Rights> list = rightsService.getRightsList(level);
        if (list.isEmpty()){
            return SysResult.failed();
        }
        return SysResult.success(list);
    }

}
